package com.neo.unittest.service;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.neo.unittest.entity.User;
import com.neo.unittest.mapper.UserMapper;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

@Service
public class UserService {

    @Resource
    private UserMapper mapper;

    public Long save(User user) {
        mapper.insert(user);
        return user.getId();
    }

    public boolean delete(Long id) {
        return mapper.deleteById(id) > 0;
    }

    public boolean update(User user) {
        return mapper.updateById(user) > 0;
    }

    public User getById(Long id) {
        return mapper.selectById(id);
    }

    public List<User> getAll() {
        return mapper.selectList(new QueryWrapper<>());
    }

}
